import { defHttp } from '/@/utils/http/axios';
import { Modal } from 'ant-design-vue';
var Api;
(function (Api) {
    Api["list"] = "/sys/business/user/listMiddle";
    Api["save"] = "/sys/business/user/addMiddle";
    Api["edit"] = "/sys/business/user/editMiddle";
    Api["queryBusinessIdByUserId"] = "/sys/business/user/queryBusinessIdByUserIdB";
    Api["deleteUser"] = "/sys/user/delete";
    Api["deleteBatch"] = "/sys/user/deleteBatch";
    Api["recycleBinList"] = "/sys/business/user/recycleBinMiddle";
    Api["putRecycleBin"] = "/sys/user/putRecycleBin";
    Api["deleteRecycleBin"] = "/sys/user/deleteRecycleBin";
    Api["changePassword"] = "/sys/user/changePassword";
    Api["frozenBatch"] = "/sys/user/frozenBatch";
})(Api || (Api = {}));
/**
 * 列表接口
 * @param params
 */
export const list = (params) => defHttp.get({ url: Api.list, params });
/**
 * 删除用户
 */
export const deleteUser = (params, handleSuccess) => {
    return defHttp.delete({ url: Api.deleteUser, params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
    });
};
/**
 * 批量删除用户
 * @param params
 */
export const batchDeleteUser = (params, handleSuccess) => {
    Modal.confirm({
        title: '确认删除',
        content: '是否删除选中数据',
        okText: '确认',
        cancelText: '取消',
        onOk: () => {
            return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
                handleSuccess();
            });
        },
    });
};
/**
 * 保存或者更新用户
 * @param params
 */
export const saveOrUpdateUser = (params, isUpdate) => {
    let url = isUpdate ? Api.edit : Api.save;
    return defHttp.post({ url: url, params });
};
/**
 * 回收站列表
 * @param params
 */
export const getRecycleBinList = (params) => defHttp.get({ url: Api.recycleBinList, params });
/**
 * 回收站还原
 * @param params
 */
export const putRecycleBin = (params, handleSuccess) => {
    return defHttp.put({ url: Api.putRecycleBin, params }).then(() => {
        handleSuccess();
    });
};
/**
 * 回收站删除
 * @param params
 */
export const deleteRecycleBin = (params, handleSuccess) => {
    return defHttp.delete({ url: Api.deleteRecycleBin, params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
    });
};
/**
 * 修改密码
 * @param params
 */
export const changePassword = (params) => {
    return defHttp.put({ url: Api.changePassword, params });
};
/**
 * 冻结解冻
 * @param params
 */
export const frozenBatch = (params, handleSuccess) => {
    return defHttp.put({ url: Api.frozenBatch, params }).then(() => {
        handleSuccess();
    });
};
/**
 * 根据中台用户ID查询绑定的商户id
 * @param params
 */
export const queryBusinessIdByUserId = (params) => defHttp.get({ url: Api.queryBusinessIdByUserId, params });
